package com.baylor.server.business.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baylor.server.base.constant.XaConstant;
import com.baylor.server.base.util.WebUitl;
import com.baylor.server.business.entity.Customer;
import com.baylor.server.business.service.CustomerService;

@Controller
@RequestMapping("xaCmsCustomer")
public class CustomerController {

	@Autowired
	private CustomerService customerService;
	
	/**
	 * @Title: showAllRole
	 * @Description: 分页显示角色
	 * @param nextPage
	 * @param sortDate
	 * @param jsonFilter
	 * @return    
	 */
	@ResponseBody
	@RequestMapping("showCustomers/{nextPage}/{sortDate}/{jsonFilter}")
	public Page<Customer> showAllRole(@PathVariable Integer nextPage,
			@PathVariable String sortDate,
			@PathVariable String jsonFilter){
		Pageable pageable = WebUitl.buildPageRequest(nextPage, 10, sortDate);
		Map<String,Object> filterParams =  WebUitl.getParametersStartingWith(jsonFilter, "search_");
		//filterParams.put("EQ_status", XaConstant.ResourcesStatus.status_normal);
		Page<Customer> data=customerService.getCustomerByCondition(filterParams, pageable);
		return data;
	}
}
